home *** CD-ROM | disk | FTP | other *** search
- /* LAP802.h contains IEEE 802.3 structure definitions
-
- (c) Copyright 1990-91 by Apple Computer, Inc. All rights reserved.
-
- */
-
- /*
- 1.2 10/11/90 Rajesh modified for IEEE 802.3 LAP.
- */
-
- #include "LAP802Arp.h"
-
- /* define structure for collecting statistics on IEEE 802.3 LAP driver */
-
- struct VBLTaskA5 {
- VBLTask VBL;
- Ptr vblA5;
- };
-
- struct type_stats {
- long pktin; /* total number of packets received */
- long broadcast; /* number of broadcasts received */
- long pktout; /* total number of packets sent */
- };
-
- struct Lap802_stats {
- long unknown; /* unknown IEEE 802.3 type values */
- struct type_stats arp; /* IEEE 802.3 ARP type statistics */
- struct type_stats ip; /* IEEE 802.3 IP type statistics */
- };
-
- typedef struct Lap802_addr {
- b_16 lap_hi;
- b_32 lap_lo;
- } Lap802_addr;
-
- typedef struct LLC_SNAP_header {
- b_8 lap_dsap; /* Destination Service Access Point */
- b_8 lap_ssap; /* Source Service Access Point */
- b_8 lap_cntl; /* control */
- b_8 lap_orghi; /* organization code, high byte */
- b_16 lap_orglo; /* organization code, 2 low bytes */
- b_16 lap_type; /* Ethertype */
- } LLC_SNAP_header;
-
- typedef struct arp_entry {
- short age; /* cache aging field */
- b_16 protocol; /* Protocol type */
- ip_addr ip_address; /* IP address */
- Lap802_addr lap_address; /* matching IEEE 802.3 address */
- };
-
- /* IEEE 802.3 ARP packet format */
- typedef struct arp_header {
- b_16 arp_hardware; /* Format of hardware address */
- b_16 arp_protocol; /* Format of protocol address */
- b_8 arp_hlen; /* Hardware address length */
- b_8 arp_plen; /* protocol address length */
- b_16 arp_opcode;
- struct Lap802_addr arp_sha; /* ARP RARP sender hardware address */
- ip_addr arp_spa; /* ARP RARP sender IP address */
- struct Lap802_addr arp_tha; /* ARP RARP target hardware address */
- ip_addr arp_tpa; /* ARP RARP target IP address */
- } ARP_header;
-
- /* ARP parameters */
- #define ARP_TABLE_SIZE 20 /* number of ARP table entries */
- #define MAX_ARP_COUNT 3 /* Max. number of ARP transmitted */
- /* before dest. is declared unknown */
-
- #define ARP_TX_INTRVL 2 /* Time interval between ARP transmission */
-
-
- struct arp_info {
- short timer; /* ARP retransmission timer */
- short rtx; /* number of retransmissions */
- ip_addr addr; /* IP address being ARPed */
- };
-
-
- /* IEEE 802.3 LAP information structure */
- struct Lap802Info {
- LAPINFO /* generic LAP info */
- /* IEEE 802.3-specific LAP variables */
- Lap802_addr our_lap_addr; /* IEEE 802.3 address for this interface */
- Lap802_addr lap_broadcast_addr; /* IEEE 802.3 broadcast address */
- struct arp_header arp_rcv; /* buffer for receiving ARP packets */
- struct ipbuf *arp_ipb; /* buffer for sending ARP requests */
- struct QHdr arp_q; /* queue of pkts waiting for ARP resolution */
- struct arp_entry arp_table[ARP_TABLE_SIZE]; /* IEEE 802.3 to IP address table */
- struct VBLTaskA5 arp_vrt_info; /* VBL info */
- struct Lap802_stats Lap802_stats; /* various LAP statistics */
- };
-
- /* define I/O Control equates for accessing/controlling the IEEE 802.3 driver */
- #define TAttachPH 247 /* Attach protocol handler */
- #define TDetachPH 248 /* Detach protocol handler */
- #define TWrite 249 /* Write */
- #define TRead 250 /* Read */
- #define TRdCancel 251 /* Cancel read */
- #define TGetInfo 252 /* Get info */
- #define TSetGeneral 253 /* Set "general" mode */
-
- /* define I/O param block for accessing IEEE 802.3 driver */
- struct Lap802PB {
- QElem *qlink;
- short qType;
- short ioTrap;
- Ptr ioCmdAddr;
- ProcPtr ioCompletion;
- OSErr ioResult;
- char *ioNamePtr;
- short ioVRefNum;
- short ioRefNum;
- short csCode; /* control code */
- union {
- struct {
- short protocolType; /* protocol type */
- ProcPtr PHaddress; /* protocol handler address */
- } TAttachPB;
- struct {
- short protocolType; /* protocol type */
- } TDetachPB;
- struct {
- short padding; /* padding */
- struct wds *wdsPtr; /* pointer to write data structure */
- } TWritePB;
- struct {
- short protocolType; /* protocol type */
- char *bufPtr; /* read buffer pointer */
- short bufSize; /* buffer size */
- short dataSize; /* data size */
- } TReadPB;
- struct {
- short padding; /* padding */
- char *infoPtr; /* pointer to info buffer */
- short bufSize; /* buffer size */
- } TGetInfoPB;
- } csParam;
- };
-
- struct wds {
- short length;
- Ptr pointer;
- };
-
-
- /* IEEE 802.3 header format */
- typedef struct Lap802_header {
- struct Lap802_addr lap_dest; /* 6 bytes destination address */
- struct Lap802_addr lap_src; /* 6 bytes source address */
- b_16 lap_len; /* 802.3 MAC header, length field */
- struct LLC_SNAP_header lap_ls; /* 8 bytes LLC and SNAP header */
- } Lap802_header;
-
- typedef struct Enet_addr {
- b_16 en_hi;
- b_32 en_lo;
- } Enet_addr;
-
- /* Ethernet header format */
- typedef struct Enet_header {
- struct Enet_addr en_dest; /* 6 bytes destination address */
- struct Enet_addr en_src; /* 6 bytes source address */
- b_16 en_type; /* protocol type */
- } Enet_header;
-
- /* Maximum IEEE 802.3 packet size */
- #define MAX_LAP802_PKT 1522 /* maximum IEEE 802.3 packet size */
- #define LAP802SPEED 10000000 /* maximum IEEE 802.3 speed 10 MB */
-
- #define LAP_IP 0x0800
- #define LAP_ARP 0x0806
- #define LAP_RARP 0x8035
-
- #define HEX_0 0x00
- #define HEX_1 0x01
- #define HEX_3 0x03
- #define HEX_5 0x05
- #define HEX_6 0x06
- #define HEX_8 0x08
- #define HEX_35 0x35
- #define HEX_80 0x80
- #define HEX_AA 0xAA
-
- /* Functions prototypes */
-
- extern OSErr Arp_init(struct Lap802Info *lap);
- extern void Arp_read_ph(struct rdStruct *rds);
- extern void RARP_read_ph(struct rdStruct *rds);
- extern struct Lap802_addr *IP_to_Lap802(struct Lap802Info *lap, ip_addr addr);
- extern void del_arp_entry(struct Lap802Info *lap, ip_addr addr);
- extern void SendARP (struct Lap802Info *lap, int arp_code, ip_addr ip_dest, Lap802_addr *lap_dest);
- extern void Arp_close(struct Lap802Info *lap);
- extern OSErr Lap802_writeit(struct Lap802Info *lap, struct ipbuf *ipb);
-
- /* definitions for MacsBug debugger */
-
- // pascal void Debugger() extern 0xa9ff;
- // pascal void DebugStr(msg) char *msg; extern 0xabff;
-